# Maintainer: Jürgen Pfeifer <juergen@familiepfeifer.de>
# Contributor: Tim S <stahta01@gmail.com>

# Pathnames in this project can get quite long, so at least on Windows
# I recommend to use a short BUILDDIR setting to avoid problems
#

_realname=xmlada-gpl
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=2017
pkgrel=2
pkgdesc="A full XML suite for Ada (mingw-w64)"
arch=('any')
provides=("${MINGW_PACKAGE_PREFIX}-${_realname%-*}")
url="https://libre.adacore.com/libre/tools/xmlada/"
license=('GPL3')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc-ada"
             "${MINGW_PACKAGE_PREFIX}-gprbuild-bootstrap-git")
depends=()
source=("${_realname}"::"git+https://github.com/AdaCore/xmlada.git#branch=gpl-${pkgver}")
sha256sums=('SKIP')
options=('strip')

prepare() {
  cd ${srcdir}/${_realname}
}

build() {
  cd ${srcdir}/${_realname}
  ./configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-shared

  make
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}/include/xmlada
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/xmlada/static
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/xmlada/relocatable
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gnat/xmlada

  cd ${srcdir}/${_realname}
  make -j1 prefix=${pkgdir}${MINGW_PREFIX} INSTALL=cp install

  rm -rf ${pkgdir}${MINGW_PREFIX}/share/examples
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/doc

  # Copy License Files
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname
  cp -pf ${srcdir}/${_realname}/COPYING* \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}
}
